
import threading
import serial.tools.list_ports
import time 
import sys

class Serial_thread (threading.Thread):
    def __init__(self, window):
        threading.Thread.__init__(self)
        self.window = window

    def check_comx(self):
        port_list = list(serial.tools.list_ports.comports())
        self.window.set_comx_cb(port_list)
        if len(port_list) <= 0:
            pass
        else:
            port_list_0 =list(port_list[0])
            port_serial = port_list_0[0]

    def run(self):
        while True:
            self.check_comx()
            time.sleep(0.1)
